package com.accelstack.cmp.service;

import com.accelstack.cmp.entity.VirtualizationPlatform;
import com.accelstack.cmp.repository.VirtualizationPlatformRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

/**
 * 虚拟化平台Service
 */
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class VirtualizationPlatformService {
    
    private final VirtualizationPlatformRepository virtPlatformRepository;
    
    @Transactional
    public VirtualizationPlatform create(VirtualizationPlatform virtPlatform) {
        return virtPlatformRepository.save(virtPlatform);
    }
    
    @Transactional
    public VirtualizationPlatform update(VirtualizationPlatform virtPlatform) {
        return virtPlatformRepository.save(virtPlatform);
    }
    
    @Transactional
    public void deleteById(Long id) {
        virtPlatformRepository.deleteById(id);
    }
    
    public Optional<VirtualizationPlatform> findById(Long id) {
        return virtPlatformRepository.findById(id);
    }
    
    public List<VirtualizationPlatform> findAll() {
        return virtPlatformRepository.findAll();
    }
    
    public Page<VirtualizationPlatform> findAll(Pageable pageable) {
        return virtPlatformRepository.findAll(pageable);
    }
}

